﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows;

namespace Desktop.Converters
{
    [ValueConversion(typeof(object), typeof(Visibility))]
    public class BooleanToVisibilityConverter : IValueConverter
    {
        #region Methods

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (bool.Parse(value.ToString()))
                {
                    return Visibility.Visible;
                }
            }
            catch (Exception)
            {
            }
            return Visibility.Hidden;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }

        #endregion
    }
}